﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 判断闰年练习
{
    class Program
    {
        static void Main(string[] args)
        {
            /*Console.WriteLine("请输入年份");
           int year= Convert.ToInt32(Console.ReadLine());
            //能被400整除
            //或者能被4整除不能被100整除；
            if (year%400==0||(year%4==0&&year%100!=0))
            {
                Console.WriteLine("{0}是闰年",year);
            }
            else
            {
                Console.WriteLine("{0}不是闰年",year);
            }
            Console.ReadKey();
            */

            Console.WriteLine("请输入年份");
            try {
                int year = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("请输入月份");
                try { 
                int month = Convert.ToInt32(Console.ReadLine());
                    if (month <=12)
                    {
                      int cmonth = 0;

                        switch (month)
                        {
                            case 4:
                            case 6:
                            case 9:
                                cmonth += 30;
                                break;
                            case 2:
                                if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0))
                                {
                                    cmonth += 29;

                                }
                                else
                                {
                                    cmonth += 28;
                                }

                                break;


                            default:
                                cmonth += 31;
                                break;
                        }
                        Console.WriteLine("{0}年{1}月有{2}天", year, month, cmonth);
                    }
                    else
                    {
                        Console.WriteLine("你输入的月份错误");

                    }
                }//try月份的括号
                catch
                {
                    Console.WriteLine("你输入的月份有错误");
                }

            }//try年份的括号
            catch
            {
                Console.WriteLine("你输入的年份有错误");
            }
            Console.ReadKey();






        }
    }
}
